package com.yh.wuye.view;

import com.yh.wuye.common.GlobalVar;
import com.yh.wuye.common.PubFun;

import android.content.Intent;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Main extends BaseActivity
{

  private Button btnPatrol;
  private Button btnTodo;
  private Button btnCharge;
  private Button btnReport;

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    initView();
  }

  @Override
  protected void initView()
  {
    super.initView();
    btnPatrol = (Button) findViewById(R.id.btnPatrol);
    btnPatrol.setOnClickListener(onPatrol);

    btnTodo = (Button) findViewById(R.id.btnTodo);
    btnTodo.setOnClickListener(onTodo);

    btnCharge = (Button) findViewById(R.id.btnCharge);
    btnCharge.setOnClickListener(onCharge);

    btnReport = (Button) findViewById(R.id.btnReport);
    btnReport.setOnClickListener(onReport);
    btnBack.setVisibility(View.GONE);
    btnExit.setOnClickListener(onExit);
  }
  
  private OnClickListener onExit = new OnClickListener()
  {
    
    @Override
    public void onClick(View v)
    {
      GlobalVar.ExitApplication = true;
      PubFun.killProcess(ctx);
    }
  };

  private OnClickListener onReport = new OnClickListener()
  {

    @Override
    public void onClick(View v)
    {
      Intent intent = new Intent(ctx, Report.class);
      startActivity(intent);
    }
  };

  private OnClickListener onPatrol = new OnClickListener()
  {

    @Override
    public void onClick(View v)
    {
      // Intent intent = new Intent(ctx, GetCodeBar.class);
      // startActivity(intent);
      // finish();

      Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
      // intent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
      // intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);

      startActivity(intent);
    }
  };

  private OnClickListener onTodo = new OnClickListener()
  {

    @Override
    public void onClick(View v)
    {
      Intent intent = new Intent(ctx, Todo.class);
      startActivity(intent);
    }
  };

  private OnClickListener onCharge = new OnClickListener()
  {

    @Override
    public void onClick(View v)
    {
      Intent intent = new Intent(ctx, CallPayMoney.class);
      startActivity(intent);
      // finish();
    }
  };

  @Override
  protected void onRestart()
  {
    super.onRestart();
    if (GlobalVar.ExitApplication)
      PubFun.killProcess(ctx);
  }

}
